import React, { Component } from 'react'
import usermodel from '../usercontorl/usercontorlmodel/usermodel'
import _ from 'lodash'
interface Istate{
    username:string,
    password:string
}
interface Iprops{
    add:(user:usermodel)=>void
}
export default class AddUser extends Component<Iprops,Istate>{
    constructor(props:Iprops){
        super(props);
        this.state={
            username:'',
            password:'',
        }
    }
  render() {
    return (
      <>
      用户名：<input type='text' value={this.state.username} onChange={(e)=>{this.setState({username:e.target.value})}}/><br/>
        密码：<input type='text' value={this.state.password} onChange={(e)=>{this.setState({password:e.target.value})}}/><br/>
        <button onClick={_.throttle(()=>{this.props.add({username:this.state.username,password:this.state.password})},3000,{leading:false,'trailing': true})}>新增</button>
      </>
    )
  }
}

